package com.jianggujin.redis.dialog;

import java.util.List;

import com.jianggujin.redis.MainFrame;
import com.jianggujin.redis.component.JEditorTable;

public class RedisPropertyDialog extends AbstractDialog {
    private JEditorTable configTable;

    private RedisPropertyDialog(MainFrame parent) {
        super(parent);
    }

    @Override
    protected void initComponent() {
        configTable = new JEditorTable(false, new String[] { "Key", "Value" });
        this.add(configTable);
    }

    @Override
    protected void initDialog() {
        setTitle("Property");
        setSize(450, 400);
        super.initDialog();
    }

    public static void showProperty(MainFrame parent, List<String> configs) {
        RedisPropertyDialog dialog = new RedisPropertyDialog(parent);
        if (configs != null) {
            int size = configs.size();
            for (int i = 0; i < size; i++) {
                dialog.configTable.addRow(new Object[] { configs.get(i), configs.get(++i) });
            }
        }
        dialog.setVisible(true);
    }
}
